package com.toy.core.security.exception;

import java.util.HashMap;
import java.util.Map;

import com.toy.core.security.SecurityRuntimeException;


public class AuthenticationException extends SecurityRuntimeException{
	
	private static final long serialVersionUID = -8849108410467862641L;
	//~ Instance fields ================================================================================================
	/**
	 * 用户名不存在
	 */
	public static Integer CODE_UsernameNotFoundException = 101;
	/**
	 * 密码错误
	 */
	public static Integer CODE_BadCredentialsException = 102;
	/**
	 * 用户被锁定
	 */
	public static Integer CODE_LockedException = 103;
	/**
	 * 用户未启用
	 */
	public static Integer CODE_DisabledException = 104;
	/**
	 * 账户过期
	 */
	public static Integer CODE_AccountExpiredException = 105;
	/**
	 * 密码过期
	 */
	public static Integer CODE_CredentialsExpiredException = 106;
	/**
	 * 并发登陆错误
	 */
	public static Integer CODE_ConcurrentLoginException = 107;
	/**
	 * 验证服务器错误
	 */
	public static Integer CODE_AuthenticationServiceException = 108;
	/**
	 * 缺乏验证
	 */
	public static Integer CODE_InsufficientAuthenticationException = 109;
	
	private static Map<Integer,String> messages = new HashMap<Integer, String>();
	
	static{
		messages.put(CODE_UsernameNotFoundException, "UsernameNotFoundException");
		messages.put(CODE_BadCredentialsException, "BadCredentialsException");
		messages.put(CODE_LockedException, "LockedException");
		messages.put(CODE_DisabledException, "DisabledException");
		messages.put(CODE_AccountExpiredException, "AccountExpiredException");
		messages.put(CODE_CredentialsExpiredException, "CredentialsExpiredException");
		messages.put(CODE_ConcurrentLoginException, "ConcurrentLoginException");
		messages.put(CODE_AuthenticationServiceException, "AuthenticationServiceException");
		messages.put(CODE_InsufficientAuthenticationException, "InsufficientAuthenticationException");
	}
	
	private Integer errorCode;
	
	public AuthenticationException(Integer errorCode) {
		super(messages.get(errorCode));
		this.errorCode  = errorCode;
	}

	public Integer getErrorCode() {
		return errorCode;
	}
	
	
}
